
package com.rt.schedulenew.web;
import java.io.IOException;
import java.io.InputStream;
import org.pegdown.PegDownProcessor;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping({ "/" })
public class VersionController
{
    @RequestMapping({ "/version" })
    public String version() throws IOException {
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("CHANGELOG.md");
        BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
        String line = null;
        String mdContent = "";
        while ((line = br.readLine()) != null) {
            mdContent = mdContent + line + "\r\n";
        }
        PegDownProcessor pdp = new PegDownProcessor(Integer.MAX_VALUE);
        String htmlContent = pdp.markdownToHtml(mdContent);
        return htmlContent;
    }
}
